package com.hualan.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.entity.Cspi;
import com.hualan.sfzy.entity.Fm;
import com.hualan.sfzy.mapper.FmMapper;
import com.hualan.sfzy.service.FmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class FmServiceImpl implements FmService {
    @Autowired
    private FmMapper fmMapper;

    @Override
    public int add(Fm entity) {
        return 0;
    }

    @Override
    public int addSelective(Fm entity){
        return fmMapper.insert(entity);
    }

    @Override
    public int edit(Fm entity) {
        return fmMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return fmMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return fmMapper.deleteBatch(ids);
    }

    @Override
    public List<Fm> find() {
        return Collections.emptyList();
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, Fm entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<Fm> list = fmMapper.selectFmAndFmClassification(entity);
        PageInfo<Fm> pageInfo = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put("pageInfo", pageInfo);
        return map;
    }

    @Override
    public Fm findById(Integer id) {
        return fmMapper.selectById(id);

    }

    public List<Fm> findFmAndFmClassificationAll(){
        return fmMapper.selectFmAndFmClassificationAll();
    }

    @Override
    public Fm findFmAndFmClassificationById(Integer id) {
        return fmMapper.selectFmAndFmClassifictionById(id);
    }

}
